package com.efast.standalone.open;

import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.efast.standalone.dao.PmAutoPrintStationDao;
import com.efast.standalone.enti.PmAutoPrintStation;
import com.efast.standalone.service.PmAutoPrintStationService;


@Component
public class ScheduledService {
	@Autowired
	private PmAutoPrintStationService printService;
	@Autowired
	private PmAutoPrintStationDao pmAutoPrintStationDao;

	//打印vin标签
	@Scheduled(fixedRate = 40000)
	@Async
	public void printVinLabel() throws ParseException, IOException {
		PmAutoPrintStation enti = new PmAutoPrintStation();
		enti.setPrintStatus("1");
		//enti.setPrintFunction("VIN_LABEL");
		enti.setPrintType("VIN_LABEL");
		List<PmAutoPrintStation> taskInfoList = pmAutoPrintStationDao.getPrintTaskInfo(enti);
		if(taskInfoList!=null && taskInfoList.size()>0) {
			for(int i=0;i<taskInfoList.size();i++) {
				enti = taskInfoList.get(i);
				//打印装车单
				String info = printService.zebraPrintVinLabel(enti);
				if(info!=null && !"".equals(info)) {
					
					System.out.println(info);
					
				}
			}
		}
		
	}
	//打印整车装车单
	@Scheduled(fixedRate = 20000)
	@Async
	public void printLoadingList() throws ParseException, IOException {
		PmAutoPrintStation enti2 = new PmAutoPrintStation();
		enti2.setPrintStatus("1");
	//	enti2.setPrintFunction("AL_TCFNS");
		enti2.setPrintType("AL_TCFNS");
		List<PmAutoPrintStation> taskInfoList = pmAutoPrintStationDao.getPrintTaskInfo(enti2);
		if(taskInfoList!=null && taskInfoList.size()>0) {
			for(int i=0;i<taskInfoList.size();i++) {
				enti2 = taskInfoList.get(i);
				//打印装车单
				String info =printService.printLoadingList(enti2);
				if(info!=null && !"".equals(info)) {
					System.out.println(info);
				}
			}
		}
		
	}
//打印驾驶室
	@Scheduled(fixedRate = 70000)
	@Async
	public void printCabList() throws ParseException, IOException {
		PmAutoPrintStation enti3 = new PmAutoPrintStation();
		enti3.setPrintStatus("1");
	//	enti3.setPrintFunction("AL_CAB");
		enti3.setPrintType("AL_CAB");
		List<PmAutoPrintStation> taskInfoList = pmAutoPrintStationDao.getPrintTaskInfo(enti3);
		if(taskInfoList!=null && taskInfoList.size()>0) {
			for(int i=0;i<taskInfoList.size();i++) {
				enti3 = taskInfoList.get(i);
				//打印驾驶室装车单
				String info =printService.printCabList(enti3);
				if(info!=null && !"".equals(info)) {
					System.out.println(info);
				}
			}
		}
	}
}
